// license-header java merge-point
package edu.uoc.tfc.gui.home;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.acegisecurity.ui.webapp.AuthenticationProcessingFilter;
import org.apache.struts.action.ActionMapping;

import edu.uoc.tfc.dto.security.UserVO;

/**
 * @see edu.uoc.tfc.gui.home.HomeController
 */
public class HomeControllerImpl extends HomeController
{
    /**
     * @see edu.uoc.tfc.gui.home.HomeController#crearMenu(org.apache.struts.action.ActionMapping, edu.uoc.tfc.gui.home.CrearMenuForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
    public final void crearMenu(ActionMapping mapping, edu.uoc.tfc.gui.home.CrearMenuForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
    {
    	//Recuperem l'usuari.
    	String userId = (String)
    			request.getSession().
    				getAttribute(AuthenticationProcessingFilter.ACEGI_SECURITY_LAST_USERNAME_KEY);
    	
        UserVO user = 
            	getSecurityService().
            		getUsuariDetall(userId);
        
        request.getSession().setAttribute("menu", 
        		getSecurityService().carregaOperacionsDelRol(
        						String.valueOf(user.getRolVO().getId())));
        
    }

}